/**
 * 
 */
package com.coder520.topic.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.reflection.wrapper.BaseWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.coder520.topic.entity.TabTopicSpeak;
import com.coder520.topic.service.TabTopicSpeakService;

/**
 * @author zhaoyibo
 *
 */
@Controller
@RequestMapping("/tabTopic/speak")
public class TabTopicSpeakController {
	
	@Autowired
	private TabTopicSpeakService tabTopicSpeakService;
	
	/**
	 * @Description:根据话题ID查询
	 * @author zhaoyibo  
	 * @date 2018年12月17日  下午5:58:46
	 */
	@RequestMapping("/query")
	@ResponseBody
	public List<TabTopicSpeak> query(HttpServletRequest request) {
		// TODO Auto-generated method stub
		String topicId = request.getParameter("topicId");
		
		Map<String, String> map=new HashMap<>();
		
		List<TabTopicSpeak> lists=new ArrayList<>();
		if (StringUtils.isEmpty(topicId)) {
			return lists;
		}
		
		lists = tabTopicSpeakService.query(map);
		map.put("topicId", topicId);
		
		return lists ;
	}
	
	@RequestMapping("save")
	@ResponseBody
	public int save(@RequestBody TabTopicSpeak tabTopicSpeak) {
		return tabTopicSpeakService.save(tabTopicSpeak);
	}
	
	
	@RequestMapping("/edit")
	
	public ModelAndView edit(HttpServletRequest request){
		String speakId = request.getParameter("speakId");
		
		TabTopicSpeak tabTopicSpeak = tabTopicSpeakService.get(speakId);
		Map<String, Object> map=new HashMap<>();
		map.put("param",tabTopicSpeak);
		return new ModelAndView("跳转地址",map);
	}
	
	
	@RequestMapping("delete")
	@ResponseBody
	public int Delete(HttpServletRequest request){
		String speakId = request.getParameter("speakId");
		return tabTopicSpeakService.delete(speakId);
	}
	
}
